package com.serkol.handler;

import com.baomidou.mybatisplus.extension.plugins.handler.TableNameHandler;

public class DynamicTableNameHandler implements TableNameHandler {
    @Override
    public String dynamicTableName(String sql, String tableName) {
        System.out.println("Index  sssssssssssssssssssssssssssssssss:"+tableName);
        System.out.println("-----------------------------------------------"+sql);
        System.out.println(tableName+"--"+sql.contains("t" + tableName));
        if (sql.contains("SELECT") && !sql.contains(tableName+" as") && !sql.contains("t" + tableName+" ")) {
            return tableName + " as x";
        } else {
            return tableName;
        }
    }
}
